package com.baturu.vin.honda.dal.dao;

import com.baturu.vin.honda.dto.HondaVinInfoDTO;
import com.baturu.vin.honda.dto.SEPCHondaMultiCarTypeDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * 本田vin车型信息DAO
 * Created by zengxuewei on 2016/12/8.
 */
public interface HondaVinDAO {

    @Select({"SELECT brand, btrId, hmodtyp, cmodnamepc, dmodyr, xcardrs, ctrsmtyp, carea, cmodtypfrm, chomolopf, nfrmpf,",
            "nfrmseqepcstrt, nfrmseqepcend, cmodtypengn, nengnpf, nengnseqepcstrt, nengnseqepcend, xgradefulnam,",
            "npl, cmftrepc, disk,brand btrBrand FROM honda_vin_info ",
            "WHERE nfrmpf = #{vinPre11}",
            "and nfrmseqepcstrt <= #{vinSuf8}",
            "and nfrmseqepcend >= #{vinSuf8}"})
    List<HondaVinInfoDTO> getVinInfo(@Param("vinPre11") String vinPre8, @Param("vinSuf8") String vinSuf8);

    @Select({"SELECT btrId, hmodtyp, cmodnamepc, dmodyr, xcardrs, ctrsmtyp, carea, cmodtypfrm, chomolopf, nfrmpf,",
            "nfrmseqepcstrt, nfrmseqepcend, cmodtypengn, nengnpf, nengnseqepcstrt, nengnseqepcend, xgradefulnam,",
            "npl, cmftrepc, disk,brand btrBrand FROM honda_vin_info ",
            "WHERE nfrmpf = #{vinPre11}",
            "and nfrmseqepcstrt <= #{vinSuf8}",
            "and nfrmseqepcend >= #{vinSuf8}",
            "AND xgradefulnam = #{xgradefulnam}",
            "AND disk = #{disk}",
            "AND carea = #{carea}",
            "AND ctrsmtyp = #{ctrsmtyp}",})
    List<HondaVinInfoDTO> getVinInfoByMulti(@Param("vinPre11") String vinPre8, @Param("vinSuf8") String vinSuf8, @Param("xgradefulnam") String xgradefulnam, @Param("ctrsmtyp") String ctrsmtyp,@Param("carea") String carea, @Param("disk") String disk);

    @Select({"SELECT btrId, hmodtyp, cmodnamepc, dmodyr, xcardrs, ctrsmtyp, carea, cmodtypfrm, chomolopf, nfrmpf,",
            "nfrmseqepcstrt, nfrmseqepcend, cmodtypengn, nengnpf, nengnseqepcstrt, nengnseqepcend, xgradefulnam,",
            "npl, cmftrepc, disk,brand btrBrand FROM honda_vin_info ",
            "WHERE nfrmpf = #{vinPre11}",
            "and nfrmseqepcstrt <= #{vinSuf8}",
            "and nfrmseqepcend >= #{vinSuf8}",
            "and disk = #{disk}",
            "AND hmodtyp = #{hmodtyp} limit 1"})
    List<HondaVinInfoDTO> getVinInfoByHmodtyp(@Param("vinPre11") String vinPre8, @Param("vinSuf8") String vinSuf8, @Param("hmodtyp") String hmodtyp, @Param("disk") String disk);

    @Select({"<script>",
            "SELECT",
            "nplblk",
            "FROM honda_pblmtt",
            "WHERE",
            "npl=#{npl}",
            "AND hmodtyp IN",
            "<foreach item='item' index='index' collection='hmodtyps' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    Set<String> getNplblkForFilter(@Param("npl") String npl, @Param("hmodtyps") Set<Integer> hmodtyps);


    @Select({"<script>SELECT hmodtyp,cmnopt FROM honda_pmtmot",
            "where hmodtyp in ",
            "<foreach item='item' index='index' collection='hmodtyps' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "AND disk = #{disk}</script>"})
    List<SEPCHondaMultiCarTypeDTO> queryCMNOPT(@Param("hmodtyps") Collection<Integer> hmodtyps, @Param("disk") String disk);

    @Select({"<script>SELECT ch,cmnopt FROM honda_pmtmot_ch",
            "where cmnopt in ",
            "<foreach item='item' index='index' collection='cmnopts' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<SEPCHondaMultiCarTypeDTO> queryCMNOPTCh(@Param("cmnopts") Collection<String> cmnopts);
}
